package com.wx.soft.contoller.sys;

import com.wx.soft.contoller.common.BaseController;
import com.wx.sys.model.SysUser;
import com.wx.sys.service.SysUserFeignApi;
import com.wx.util.R;
import com.wx.util.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by king-pc on 2018/12/4.
 */
@RestController
@RequestMapping("/login")
public class LoginController extends BaseController {

    @Autowired
    private SysUserFeignApi sysUserFeignApi;

    /**
     *
     * @param request
     * @param sysUser
     * @return
     */
    @PostMapping("/userLogin")
    public String userLogin(HttpServletRequest request,SysUser sysUser){
        SysUser user = sysUserFeignApi.getUserInfo(sysUser.getAccount());
        if(user==null){
            return R.error(ResponseObject.status_512,"用户名不存在！");
        }
        this.putUserToSession(request,user);
        return R.ok();
    }

}
